/**
 * author      : dormi330
 * date        : 2018/6/24
 * description : 订单, 按照店铺进行隔离, 拥有一个或多个SKU
 * <p>
 * 一个订单包含多条 item, 但是一次支付
 * 物流可以包含多个
 */

package com.deep.trade.domain.order;


import com.deep.trade.common.BaseEntity;
import com.deep.trade.common.CommonUtils;
import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;
import java.util.Date;

public class TradeOrderHistory extends BaseEntity {

    private String tradeOrderId;
    private String orderSummaryId;              // 交易父订单(OrderSummary)id
    private String orderType;                   // 订单类型 目前只支持普通订单 general
    private String channelCode;                 // 订单渠道
    private String channelName;                 // 订单渠道
    private String code;                        // 订单编码

    private String sellerId;                    // 卖家Id
    private String sellerName;                  // 卖家名称
    private String shopId;                      // 店铺Id
    private String memberId;                    // 会员Id
    private String memberName;                  // 会员名称
    private String remark;                      // 备注
    private String sellerRemark;                // 卖家备注
    private String status;                      // 订单状态, 枚举

    // 与金额相关的信息
    private BigDecimal skuDiscountMoney;        // sku级优惠额度
    private BigDecimal shopDiscountMoney;       // sku级优惠额度
    private BigDecimal platformDiscountMoney;   // 平台优惠
    private BigDecimal freightMoney;            // 订单运费金额小计, 计算值
    private BigDecimal itemMoney;               // 商品金额小计, 计算值
    private BigDecimal payMoney;                // 实付金额, 计算值

    private String auditRejectReason;           // 审核拒绝原因
    private Date auditedAt;                     // 审核时间
    private Date finishedAt;                    // 完成时间
    private int plock;                          // 锁, 1=被锁, 0=无锁, 在支付时用到

    public static TradeOrderHistory fromTradeOrder(TradeOrder tradeOrder) {
        TradeOrderHistory history = new TradeOrderHistory();
        BeanUtils.copyProperties(tradeOrder, history);

        history.setId(CommonUtils.uuid());
        history.setTradeOrderId(tradeOrder.getId());
        history.setCreatedAt(new Date());
        history.setUpdatedAt(null);
        return history;
    }

    public Date getFinishedAt() {
        return finishedAt;
    }

    public void setFinishedAt(Date finishedAt) {
        this.finishedAt = finishedAt;
    }

    public String getTradeOrderId() {
        return tradeOrderId;
    }

    public void setTradeOrderId(String tradeOrderId) {
        this.tradeOrderId = tradeOrderId;
    }

    public String getOrderSummaryId() {
        return orderSummaryId;
    }

    public void setOrderSummaryId(String orderSummaryId) {
        this.orderSummaryId = orderSummaryId;
    }

    public String getOrderType() {
        return orderType;
    }

    public void setOrderType(String orderType) {
        this.orderType = orderType;
    }

    public String getChannelCode() {
        return channelCode;
    }

    public void setChannelCode(String channelCode) {
        this.channelCode = channelCode;
    }

    public String getChannelName() {
        return channelName;
    }

    public void setChannelName(String channelName) {
        this.channelName = channelName;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getSellerId() {
        return sellerId;
    }

    public void setSellerId(String sellerId) {
        this.sellerId = sellerId;
    }

    public String getSellerName() {
        return sellerName;
    }

    public void setSellerName(String sellerName) {
        this.sellerName = sellerName;
    }

    public String getShopId() {
        return shopId;
    }

    public void setShopId(String shopId) {
        this.shopId = shopId;
    }

    public String getMemberId() {
        return memberId;
    }

    public void setMemberId(String memberId) {
        this.memberId = memberId;
    }

    public String getMemberName() {
        return memberName;
    }

    public void setMemberName(String memberName) {
        this.memberName = memberName;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getSellerRemark() {
        return sellerRemark;
    }

    public void setSellerRemark(String sellerRemark) {
        this.sellerRemark = sellerRemark;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public BigDecimal getSkuDiscountMoney() {
        return skuDiscountMoney;
    }

    public void setSkuDiscountMoney(BigDecimal skuDiscountMoney) {
        this.skuDiscountMoney = skuDiscountMoney;
    }

    public BigDecimal getShopDiscountMoney() {
        return shopDiscountMoney;
    }

    public void setShopDiscountMoney(BigDecimal shopDiscountMoney) {
        this.shopDiscountMoney = shopDiscountMoney;
    }

    public BigDecimal getPlatformDiscountMoney() {
        return platformDiscountMoney;
    }

    public void setPlatformDiscountMoney(BigDecimal platformDiscountMoney) {
        this.platformDiscountMoney = platformDiscountMoney;
    }

    public BigDecimal getFreightMoney() {
        return freightMoney;
    }

    public void setFreightMoney(BigDecimal freightMoney) {
        this.freightMoney = freightMoney;
    }

    public BigDecimal getItemMoney() {
        return itemMoney;
    }

    public void setItemMoney(BigDecimal itemMoney) {
        this.itemMoney = itemMoney;
    }

    public BigDecimal getPayMoney() {
        return payMoney;
    }

    public void setPayMoney(BigDecimal payMoney) {
        this.payMoney = payMoney;
    }

    public String getAuditRejectReason() {
        return auditRejectReason;
    }

    public void setAuditRejectReason(String auditRejectReason) {
        this.auditRejectReason = auditRejectReason;
    }

    public Date getAuditedAt() {
        return auditedAt;
    }

    public void setAuditedAt(Date auditedAt) {
        this.auditedAt = auditedAt;
    }

    public int getPlock() {
        return plock;
    }

    public void setPlock(int plock) {
        this.plock = plock;
    }
}
